package com.bidbid.item.dao.impl;

import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.bidbid.item.dao.IItemManager;
import com.bidbid.item.dao.domain.Item;
import com.ibatis.sqlmap.client.SqlMapClient;

@Repository
public class ItemManagerImpl extends SqlMapClientDaoSupport implements
		IItemManager {
	public void setSqlMapClientBase(SqlMapClient sqlMapClient) {
		super.setSqlMapClient(sqlMapClient);
	}

	@Override
	public List<Item> listItems() throws SQLException {
		SqlMapClient client = this.getSqlMapClient();
		return client.queryForList("selectAllItems");
	}

	@Override
	public void addItem(Item item) throws SQLException {
		SqlMapClient client = this.getSqlMapClient();
		client.insert("insertItem", item);
	}

	@Override
	public List<Item> getRecommendedItems() throws SQLException {
		SqlMapClient client = this.getSqlMapClient();
		return client.queryForList("getRecommendedItem");
	}
}
